#include "zgsprite.h"

// 简单的绘画程序示例
int main() {
    // 初始化窗口
    Window::Init(800, 600, "我的绘画板");
    
    // 创建画笔
    Pen pen;
    pen.SetColor(BLUE);
    pen.SetThickness(3.0f);
    
    // 加载中文字体
    pen.LoadCustomFont("fonts/GB_ST_GB18030.ttf");
    
    // 画笔初始位置
    pen.SetPosition(400, 300);
    
    // 游戏主循环
    while (!Window::ShouldClose()) {
        // 处理输入
        if (Keyboard::IsKeyDown(KEY_RIGHT)) pen.SetPosition(pen.GetPosition().x + 5, pen.GetPosition().y);
        if (Keyboard::IsKeyDown(KEY_LEFT)) pen.SetPosition(pen.GetPosition().x - 5, pen.GetPosition().y);
        if (Keyboard::IsKeyDown(KEY_DOWN)) pen.SetPosition(pen.GetPosition().x, pen.GetPosition().y + 5);
        if (Keyboard::IsKeyDown(KEY_UP)) pen.SetPosition(pen.GetPosition().x, pen.GetPosition().y - 5);
        
        // 改变颜色
        if (Keyboard::IsKeyPressed(KEY_R)) pen.SetColor(RED);
        if (Keyboard::IsKeyPressed(KEY_G)) pen.SetColor(GREEN);
        if (Keyboard::IsKeyPressed(KEY_B)) pen.SetColor(BLUE);
        if (Keyboard::IsKeyPressed(KEY_Y)) pen.SetColor(YELLOW);
        
        // 改变线条粗细
        if (Keyboard::IsKeyPressed(KEY_EQUAL)) pen.SetThickness(pen.GetThickness() + 1.0f);
        if (Keyboard::IsKeyPressed(KEY_MINUS)) pen.SetThickness(pen.GetThickness() - 1.0f);
        
        // 抬起/放下画笔
        if (Keyboard::IsKeyPressed(KEY_SPACE)) {
            if (pen.IsPenDown()) pen.PenUp();
            else pen.PenDown();
        }
        
        // 开始绘制
        Window::BeginDraw();
        
        // 显示操作说明
        Pen textPen;
        textPen.SetColor(BLACK);
        textPen.DrawText("方向键: 移动画笔", 20, 20, 20);
        textPen.DrawText("R/G/B/Y: 改变颜色", 20, 50, 20);
        textPen.DrawText("+/-: 改变线条粗细", 20, 80, 20);
        textPen.DrawText("空格: 抬起/放下画笔", 20, 110, 20);
        
        // 结束绘制
        Window::EndDraw();
    }
    
    // 关闭窗口
    Window::Close();
    
    return 0;
}